package com.digua.base.util

import android.content.Context
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.CacheDiskUtils
import com.blankj.utilcode.util.CacheDoubleUtils
import com.blankj.utilcode.util.CacheMemoryUtils
import com.blankj.utilcode.util.CleanUtils
import com.blankj.utilcode.util.CrashUtils
import com.blankj.utilcode.util.PathUtils
import com.blankj.utilcode.util.Utils
import com.blankj.utilcode.util.ViewUtils
import java.util.Locale


object AppUtil {
    const val mi = "mi"
    const val he = "he"

    /**
     * 清理垃圾
     */
    fun cleanGarbage() {
        ViewUtils.runOnUiThread {
            try {
                LogUtil.d("================>>>cleanGarbage")
                System.gc()
                CleanUtils.cleanExternalCache()
                CleanUtils.cleanCustomDir(PathUtils.getFilesPathExternalFirst())
                CacheDiskUtils.getInstance().clear()
                CacheMemoryUtils.getInstance().clear()
                CacheDoubleUtils.getInstance().clear()
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }
    }

    fun setLanguage(language: Locale?){
        if(language == null) return
        AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(language.language))
    }

}